﻿using System;
using System.Collections.Generic;
using System.Drawing;
using ZedGraph;
using NeuronDotNet;

namespace AdvancedTSPSolver
{
  /// <summary>
  /// Class nested from River library class. Can in addition draw river 
  /// and bridges.
  /// Authors: Savenko Maria, Skorodumov Kirill.
  /// </summary>
  public class DrawableRiver : River
  {
    #region private fields
    private Color defaultBridgesColor = Color.Black;
    private string defaultPointAllias = string.Empty;
    private const FillType defaultBridgesFillType = FillType.Solid;
    private const float defaultBridgesPointSize = 10;
    #endregion

    #region public methods
    public DrawableRiver() : base() { }

    /// <summary>
    /// Adds river curve to graph.
    /// </summary>
    /// <param name="lineItem">Line Item to add river to.</param>
    /// <param name="control">Graph to help adding elements.</param>
    public void AddRiverToGraph(ZedGraphControl control)
    {
      //make two arrays of double values for river 
      //points for easier work with them
      Dictionary<string, double[]> groupedCoordinates =
        Utils.SeparateIntoCoordinatesArrays(RiverBank);
      double[] riverX = groupedCoordinates["x"];
      double[] riverY = groupedCoordinates["y"];

      //adds a simple curve to the graph representing the river
      control.GraphPane.AddCurve(
        defaultPointAllias, riverX, riverY, Color.Red, SymbolType.None);
    }

    /// <summary>
    /// Adds bridges square points to graph.
    /// </summary>
    /// <param name="lineItem">Line Item to add bridges to.</param>
    /// <param name="control">Graph to help adding elements.</param>
    public void AddBridgesToGraph(ZedGraphControl control)
    {
      //makes two arrays of double values for bridges 
      //points for easier the work with them
      Dictionary<string, double[]> groupedCoordinates =
        Utils.SeparateIntoCoordinatesArrays(Bridges);
      double[] bridgeX = groupedCoordinates["x"];
      double[] bridgeY = groupedCoordinates["y"];

      //adds bridges to the graph as squares
      LineItem lineItem = control.GraphPane.AddCurve(
        defaultPointAllias, bridgeX, bridgeY, defaultBridgesColor, SymbolType.Square);
      lineItem.Line.IsVisible = false;
      lineItem.Symbol.Fill.Type = defaultBridgesFillType;
      lineItem.Symbol.Fill.Color = defaultBridgesColor;
      lineItem.Symbol.Size = defaultBridgesPointSize;
    }
    #endregion
  }
}
